home *** CD-ROM | disk | FTP | other *** search
- /* strcmp.c From TC Bible page 276 Use strcmp to compare one string
- to another. The comparision is case sensitive. */
-
- #include <stdio.h>
- #include <string.h>
- main()
- {
- int result;
- char str1[80], str2[80];
- printf("Enter a string: ");
- gets(str1);
- printf("Enter a string to compare with first: ");
- gets(str2);
- result = strcmp(str1, str2);
- if (result == 0)
- {
- printf("\"%s\" == \"%s\"\n", str1, str2);
- }
- if (result < 0)
- {
- printf("\"%s\" < \"%s\"\n", str1, str2);
- }
- if (result > 0)
- {
- printf("\"%s\" > \"%s\"\n", str1, str2);
- }
- }